package com.aishare.qicaitaoke.utils;

import android.content.Context;
import android.widget.ImageView;

import com.aishare.qicaitaoke.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
 * 作者luwenming
 * 时间2018/1/31
 */

public class ImageLoadUtils {

    public static void  display(Context context, ImageView imageView ,String url){
        if(imageView==null){
            throw new IllegalArgumentException("参数错误");
        }
        Glide.with(context).load(url)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .centerCrop()
                .placeholder(R.mipmap.ic_launcher_round)
                .error(R.drawable.ic_launcher_background)
                .crossFade().into(imageView);
    }

    public static void displayHigh(Context context,ImageView imageView ,String url){
        if(imageView == null){
            throw new IllegalArgumentException("参数错误");
        }
        Glide.with(context).load(url)
                .asBitmap()
                .format(DecodeFormat.PREFER_ARGB_8888)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .centerCrop()
                .placeholder(R.drawable.ic_launcher_foreground)
                .error(R.drawable.ic_launcher_background)
                .into(imageView);
    }
}
